package com.byjh.app.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.byjh.app.mapper.ChapterMapper;
import com.byjh.app.domain.Chapter;
import com.byjh.app.service.IChapterService;

/**
 * 题库章节Service业务层处理
 * 
 * @author Dhq
 * @date 2025-01-15
 */
@Service
public class ChapterServiceImpl implements IChapterService 
{
    @Autowired
    private ChapterMapper chapterMapper;

    /**
     * 查询题库章节
     * 
     * @param id 题库章节主键
     * @return 题库章节
     */
    @Override
    public Chapter selectChapterById(Long id)
    {
        return chapterMapper.selectChapterById(id);
    }

    /**
     * 查询题库章节列表
     * 
     * @param chapter 题库章节
     * @return 题库章节
     */
    @Override
    public List<Chapter> selectChapterList(Chapter chapter)
    {
        return chapterMapper.selectChapterList(chapter);
    }


    /**
     * 查询用户的章节列表及当前章节的进度
     *
     * @param userId
     * @return
     */
    @Override
    public List<Chapter> selectChapterListAndProgressByUserId(Long userId){
        return chapterMapper.selectChapterListAndProgressByUserId(userId);
    }

    /**
     * 新增题库章节
     * 
     * @param chapter 题库章节
     * @return 结果
     */
    @Override
    public int insertChapter(Chapter chapter)
    {
        return chapterMapper.insertChapter(chapter);
    }

    /**
     * 修改题库章节
     * 
     * @param chapter 题库章节
     * @return 结果
     */
    @Override
    public int updateChapter(Chapter chapter)
    {
        return chapterMapper.updateChapter(chapter);
    }

    /**
     * 批量删除题库章节
     * 
     * @param ids 需要删除的题库章节主键
     * @return 结果
     */
    @Override
    public int deleteChapterByIds(Long[] ids)
    {
        return chapterMapper.deleteChapterByIds(ids);
    }

    /**
     * 删除题库章节信息
     * 
     * @param id 题库章节主键
     * @return 结果
     */
    @Override
    public int deleteChapterById(Long id)
    {
        return chapterMapper.deleteChapterById(id);
    }

    @Override
    public void updateChapterQuantityByChapterId(Long id) {
        chapterMapper.updateChapterQuantityByChapterId(id);
    }
}
